#include "tcptool.h"


tcpTool::tcpTool(QObject *parent) :QObject(parent){
    tcp_server=new QTcpServer(this);
    tcp_server->listen(QHostAddress::Any,port);
    // qDebug()<<"1";
    connect(tcp_server,&QTcpServer::newConnection,this,[this](){
        // qDebug()<<1222;
        // QTcpSocket *tcp_socket=tcp_server->nextPendingConnection();

        // connect(tcp_socket,&QTcpSocket::readyRead,this,[](){
        //     qDebug()<<"11111";
        // });

        // qDebug()<<"123";
        childThread *childThread=
        new class childThread(tcp_server->nextPendingConnection(),this);
        // childThread->setDb(this->getDb());
        childThread->start();
        // QThreadPool::globalInstance()->start(childThread);
    });

}

const QSqlDatabase *tcpTool::getDb() const
{
    return db;
}

void tcpTool::setDb(const QSqlDatabase *newDb)
{
    db = newDb;
}
